﻿@model WaiGaoQiaoWeb.Models.TempCardInfoVM
@{
    ViewBag.Title = "TempCardInfoIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
    <script type="text/javascript" language="javascript">
        var maiheight = document.documentElement.clientHeight;
        var mainWidth = document.documentElement.clientWidth - 10; // 减去边框和左边的宽度
        $(document).ready(function () {
            var otherpm = $("#title").height() + $("#findDiv").height(); // 290;
            var gh = maiheight - otherpm - 80;
            var option = {
                height: gh,
                width: mainWidth,
                url: '@Url.Action("GetList")', // 参数要放在）括号的外面
                dataType: 'json',
                colModel: [
                    { display: 'PID', name: 'PID', width: 70, sortable: false, hide: true, align: 'left', iskey: true },
                    { display: '部门名称', name: 'DeptName', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '班组', name: 'GroupName', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '岗位', name: 'StructrueName', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '人员编号', name: 'EMPNO', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '姓名', name: 'PName', width: 50, sortable: false, hide: false, align: 'left' },
                    { display: '卡状态', name: 'CARDSTATUS', width: 50, sortable: false, hide: false, align: 'left' },
                    { display: '卡序列号', name: 'CARDSERIAL', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '卡内余额', name: 'Balance', width: 70, sortable: false, hide: false, align: 'left' },
                    { display: '入职日期', name: 'EnrollDate', width: 100, sortable: false, hide: false, align: 'left' }
				],
                buttons: [
                            { name: 'Edit', displayname: "修改", title: "修改", bclass: 'edit', onpress: toolbarItemEdit_onclick },
							{ separator: true }
						 ],
                title: false,
                singleselected: false,
                usepager: true,
                resizable: true,
                page: 1, //默认当前页  
                total: 1, //总页面数  
                useRp: true, //是否可以动态设置每页显示的结果数  
                rp: 20, // 每页默认的结果数  
                rpOptions: [10, 15, 20], //可选择设定的每页结果数
                showcheckbox: true,
                selectedonclick: true,
                rowbinddata: true,
                query: '',
                hideOnSubmit: true, //隐藏提交  
                autoload: true
            };
            $("#TempcardInfoTable").flexigrid(option);
            $("#butfind").click(function (e) {
                option.query = $("#txtPName").val() + "," + $("#DEP_ID :selected").val() + "," + $("#txtEmpNo").val() + "," + $("#txtCardSerial").val() + ',' + $("#GroupIdDept :selected").val() + ',' + $("#structrueId :selected").val() + "," + $("#KZT :selected").val();
                option.newp = 0;
                $('#TempcardInfoTable').flexOptions(option).flexReload();
            });
            $("#DEP_ID").change(function (e) {
                var vdepid = $("#DEP_ID :selected").val();
                $.ajax({
                    type: "POST",
                    url: '@Url.Action("GetGroupDeptChange")',
                    data: { depid: vdepid },
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        $("#GroupIdDept").empty();
                        var t = $("#GroupIdDept")
                        for (var i in data) {
                            var x = data[i];
                            t.append("<option value='" + x.Value + "'>" + x.Text + "</option>");
                        }
                    },
                    error: function () { }
                });
            });
            function SelectClick() {
                option.query = $("#txtPName").val() + "," + $("#DEP_ID :selected").val() + "," + $("#txtEmpNo").val() + "," + $("#txtCardSerial").val() + ',' + $("#GroupIdDept :selected").val() + ',' + $("#structrueId :selected").val() + "," + $("#KZT :selected").val();
                option.newp = 0;
                $('#TempcardInfoTable').flexOptions(option).flexReload();
            }
            function toolbarItemEdit_onclick(cmd, grid) {
                var items = $("#TempcardInfoTable").getSelectedRows();
                if (items.length == 0) {
                    showLoadingMsg("请选择要编辑的人员!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                if (items.length > 1) {
                    showLoadingMsg("只能选择一个要编辑的人员!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                var ID = items[0][0];
                OpenModelWindow('@Url.Action("EditTempCardInfo")?id=' + ID,
                 { width: 400, height: 450, caption: "修改", onclose: refresh });
            }
            function refreshGrid() {
                $("#TempcardInfoTable").flexReload();
            }
            $("#DEP_ID").bind('keydown', function (e) {
                var key = e.which;
                if (key == 13) {
                    e.preventDefault();
                    SelectClick();
                }
            });
            $("#txtPName").bind('keydown', function (e) {
                var key = e.which;
                if (key == 13) {
                    e.preventDefault();
                    SelectClick();
                }
            });
            $("#txtEmpNo").bind('keydown', function (e) {
                var key = e.which;
                if (key == 13) {
                    e.preventDefault();
                    SelectClick();
                }
            });
            $("#txtCardSerial").bind('keydown', function (e) {
                var key = e.which;
                if (key == 13) {
                    e.preventDefault();
                    SelectClick();
                }
            });
            function refresh() {
                showLoadingMsg("保存成功", { left: 200, top: 6 }, true, 3000);
                $("#TempcardInfoTable").flexReload();
            }
        });
    </script>
}
<div id="container_sx">
    <div id="mainContent">
        <div id="findDiv">
            <table>
                <tr>
                    <td style="text-align: right;">
                        &nbsp;部门名称：
                    </td>
                    <td style="text-align: left;">
                        @Html.DropDownListFor(model => model.DEP_ID,
                                   ViewData["Deptment"] as IEnumerable<SelectListItem>,
                                   new { @style = "width:160px; height:22px; font-size:13px;" })
                    </td>
                    <td style="text-align: right;">
                        &nbsp;班组：
                    </td>
                    <td style="text-align: left;">
                        @Html.DropDownListFor(model => model.GroupIdDept,
                                   ViewData["GroupDept"] as IEnumerable<SelectListItem>,
                                   new { @style = "width:160px; height:22px; font-size:13px;" })
                    </td>
                    <td style="text-align: right;">
                        &nbsp;姓名：
                    </td>
                    <td style="text-align: left;">
                        @Html.TextBox("txtPName", "", new { @style = "width:150px;" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;">
                        &nbsp;人员编号：
                    </td>
                    <td style="text-align: left;">
                        @Html.TextBox("txtEmpNo", "", new { @style = "width:150px;" })
                    </td>
                    <td style="text-align: right;">
                        &nbsp;卡序列号：
                    </td>
                    <td style="text-align: left;">
                        @Html.TextBox("txtCardSerial", "", new { @style = "width:150px;" })
                    </td>
                    <td style="text-align: right;">
                        &nbsp;岗位名称：
                    </td>
                    <td style="text-align: left;">
                        @Html.DropDownListFor(model => model.structrueId,
                                            ViewData["StructrueName"] as IEnumerable<SelectListItem>,
                                   new { @style = "width:160px; height:22px; font-size:13px;" })
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;">
                        &nbsp;卡状态：
                    </td>
                    <td style="text-align: left;">
                        @Html.DropDownListFor(model => model.KZT,
                                   ViewData["KZT"] as IEnumerable<SelectListItem>,
                                   new { @style = "width:160px; height:22px; font-size:13px;" })
                    </td>
                    <td colspan="4">
                        <a id="butfind" class="button" href="javascript:void(0);"><span>查询</span></a>
                    </td>
                </tr>
            </table>
        </div>
        <table id="TempcardInfoTable" style="display: none;">
        </table>
    </div>
</div>
